﻿using CodeGenerator.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeGenerator.Template.Web.Views
{
    public partial class PopLookup : ITemplate
    {
        public MetaData Data { get; set; }
        public List<LookupClassModel> lookups { get; set; }
        public List<PickupListModel> pickuplist { get; set; }

        public string Filename
        {
            /* apple
             * get { return "{ClassName}PopLookup.cshtml"; }
            */
            get { return "{ClassName}_{AttributeName}PopExternalLookup.cshtml"; }
        }

        public bool IsLookup(string modelName)
        {
            foreach (var lookup in lookups)
            {
                if (lookup.Name.Equals(modelName)) return true;
            }
            return false;
        }

        public List<ClassModel> GetAllLookupClass(List<ClassModel> models)
        {
            List<ClassModel> list = new List<ClassModel>();
            foreach (ClassModel c in models)
            {
                ClassModel c2 = c.GetAllLookup();
                if (c2._attributes.Count > 0)
                {
                    list.Add(c2);
                }
            }
            return list;
        }

        public bool IsGenerateOneTime { get { return false; } }
        public bool IsGenerateFolder { get { return true; } }
        public bool IsRequiredOnlyOneMember { get { return true; } }
        public GenerateStyle GenerateStyle { get { return GenerateStyle.LookUp; } }
    }
}
